<template>
  <div>
    <NavBar />
    <div class="work-show-top">
      <img :src="workUrlOne" class="work-show-top-img" />
    </div>

    <!-- 在展厅区域下方添加VR展厅标题 -->
    <div :style="{ opacity: showBox ? 1 : 0 }" :class="{ 'animate__bounceInUp': showAnimation }"
      class="animate__animated vrbox">
      <div class=" exhibition-hall" :style="{ opacity: showBox ? 1 : 0 }">
        <div class="hall-container">
          <div class="arrow-group left  animate__animated " :class="{ 'animate__bounceInLeft': showAnimation }">
            <img :src="left" fit="fill" v-for=" item  in   7  " :key="item" :style="{ opacity: showBox ? 1 : 0 }"
              class="arrow-img" />
          </div>
          <div class="exhibition-title-box" :class="{ 'animate__bounceInUp': showAnimation }">
            <h2>{{ schoolWorkName }}</h2>
          </div>
          <div class="arrow-group left animate__animated  " :class="{ 'animate__bounceInRight': showAnimation }">
            <img :src="right" fit="fill" v-for="   item   in   7  " :key="item" :style="{ opacity: showBox ? 1 : 0 }"
              class="arrow-img" />
          </div>
        </div>
      </div>
      <div class="vr-exhibition-title" :class="{ 'animate__bounceInUp': showAnimation }"
        :style="{ opacity: showBox ? 1 : 0 }">
        <h1 class="vr-title">{{ vrzhnam }}</h1>
        <h2 class="vr-subtitle">{{ vrengname }}
        </h2>
      </div>
      <img :src="vr" fit="fill" :style="{ opacity: showBox ? 1 : 0 }" class="vr animate__animated"
        :class="{ 'animate__bounceInUp': showAnimation }" />
    </div>



    <div class=" animate__animated major-box" :style="{ opacity: showBox ? 1 : 0 }"
      :class="{ 'animate__bounceInUp': showMajorAnimation }">
      <div class="majorView">
        <img :src="majorTitle" fit="fill" class="majotTitle " />
        <img :src="majorEngName" fit="fill" class="majorEngName " />
        <img :src="majorZhName" fit="fill" class="majorZhName " />
        <img :src="majorBorder" fit="fill" class="majotBorder " />
      </div>
      <div class="major-sortbox">
        <ul class="major-sort">
          <li class="major-item major-one" v-for="(item, index) in major" :key="index">
            <span class="major-title-zhname">{{ item.zhname }}</span>
            <span class="major-title-name">{{ item.engname }}</span>
            <img :src="item.img" fit="fill" class="major-img " />
          </li>
        </ul>
      </div>
    </div>
    <div class="more-work">
      <h1 class="more-work-title">
        <span class="more-work-zh-title">{{ moreWorkZhiTtle }}</span>
        <span class="more-work-eng-title"> {{ moreWorkEngTitle }}</span>
      </h1>
      <div class="more-work-list-box">
        <div class="more-work-list-box-top">

        </div>
        <div class="more-work-box">
          <ul class="more-work-list">
            <li class="more-work-item" v-for="(item, index) in moreWorks" :key="index">
              <img :src="item.img" fit="fill" class="more-work-img">
              <p class="more-work-name">{{ item.title }}</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <Footer />
  </div>
</template>

<script setup lang="ts">
import 'animate.css'
import { ref, onMounted, onUnmounted } from 'vue'
import { NavBar } from '@/components/layout/components/NavBar/index'
import { Footer } from '@/components/layout/components/footer/index'
const workUrlOne = '/src/assets/schoolWorkInfo/work-header.png';
const left = '/src/assets/schoolWorkInfo/left.png';
const right = '/src/assets/schoolWorkInfo/right.png';
const vr = '/src/assets/schoolWorkInfo/VR.png';
const majorTitle = '/src/assets/schoolWorkInfo/major-title.png';
const majorEngName = '/src/assets/schoolWorkInfo/major-engName.png';
const majorZhName = '/src/assets/schoolWorkInfo/major-zhName.png';
const majorBorder = '/src/assets/schoolWorkInfo/major-border.png';
const schoolWorkName = "武汉科技大学2024界毕业设计作品联展"
const vrzhnam = "沉浸式VR虚拟展厅"
const vrengname = "Immersive VR VIRTUAL Exhibition Hall";
const moreWorkZhiTtle = "查看更多/";
const moreWorkEngTitle = "view more";
const major = ref([
  {
    zhname: "视觉传达设计/",
    engname: "visual commounication design",
    img: "/src/assets/schoolWorkInfo/major-sort-one.png"
  },
  {
    zhname: "环境设计/",
    engname: "environmental design",
    img: "/src/assets/schoolWorkInfo/major-sort-two.png"
  },
  {
    zhname: "产品设计/",
    engname: "product design",
    img: "/src/assets/schoolWorkInfo/major-sort-three.png"
  },
  {
    zhname: "工业设计/",
    engname: "industrial design",
    img: "/src/assets/schoolWorkInfo/major-sort-one.png"
  },
  {
    zhname: "绘画/",
    engname: "drawing",
    img: "/src/assets/schoolWorkInfo/major-sort-two.png"
  }
])
const moreWorks = ref(
  [
    {
      img: "/src/assets/schoolWorkInfo/more-work-one.png",
      title: "2024鲁迅美术学院本科生毕业作品展"
    }, {
      img: "/src/assets/schoolWorkInfo/more-work-two.png",
      title: "2024世界树-中国美术学院本科生毕业作品展"
    }, {
      img: "/src/assets/schoolWorkInfo/more-work-three.png",
      title: "2024四川美术学院艺术游本科生毕业作品展"
    }
    , {
      img: "/src/assets/schoolWorkInfo/more-work-four.png",
      title: "2024湖北美术学院本科生毕业作品展"
    }

  ])
// vr动画效果
const showAnimation = ref(false)
const showBox = ref(false)
const isVrBoxVisible = ref(false)
// 专业动画
const isMajorBoxVisible = ref(false)
const showMajorBox = ref(false)
const showMajorAnimation = ref(false)

const checkVrBoxPosition = () => {
  const posterElement = document.querySelector('.vrbox')

  if (posterElement) {
    const rect = posterElement.getBoundingClientRect()
    // 当元素的顶部进入视口时
    if (rect.top <= window.innerHeight * 0.5) {
      isVrBoxVisible.value = true
      showAnimation.value = true
      showBox.value = true
    }
  }
}

const checkMajorBoxPosition = () => {
  const majorElement = document.querySelector('.major-box');
  if (majorElement) {
    const rect = majorElement.getBoundingClientRect();
    if (rect.top <= window.innerHeight * 0.9) {
      isMajorBoxVisible.value = true;
      showMajorBox.value = true;
      showMajorAnimation.value = true;
    }
  }
}

const scrollToVrBox = () => {
  const posterElement = document.querySelector('.vrbox')
  if (posterElement) {
    const offset = -10
    const elementRect = posterElement.getBoundingClientRect()
    const absoluteElementTop = elementRect.top + window.pageYOffset
    const middle = absoluteElementTop - (window.innerHeight / 2) + (elementRect.height / 2) - offset
    window.scrollTo({
      top: middle,
      behavior: 'smooth'
    })
  }
}

const scrollToMajorBox = () => {
  const posterElement = document.querySelector('.major-box')
  if (posterElement) {
    const offset = -10
    const elementRect = posterElement.getBoundingClientRect()
    const absoluteElementTop = elementRect.top + window.pageYOffset
    const middle = absoluteElementTop - (window.innerHeight / 2) + (elementRect.height / 2) - offset
    window.scrollTo({
      top: middle,
      behavior: 'smooth'
    })
  }
}



onMounted(() => {
  window.addEventListener('scroll', checkVrBoxPosition)
  window.addEventListener('scroll', checkMajorBoxPosition)
  scrollToVrBox() // 初始滚动到位置
  scrollToMajorBox();
})

onUnmounted(() => {
  window.removeEventListener('scroll', checkVrBoxPosition)
  window.removeEventListener('scroll', checkMajorBoxPosition)

})

</script>

<style scoped>
.work-show-top {
  width: 100%;
  height: 100vh;
}

.work-show-top .work-show-top-img {
  width: 100%;
  height: 100vh;
}

.vr {
  width: 100%;
  height: 60vh;
}

/* 添加展厅样式 */
.exhibition-hall {
  width: 100%;
  padding: 60px 0;
  padding-bottom: 20px;
}

.hall-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  gap: 30px;
}

.exhibition-title-box {
  background: #c02431;
  color: white;
  padding: 0px 30px;
  border-radius: 50px;
  text-align: center;
  justify-items: center;
  height: 40px;
}

.exhibition-title-box h2 {
  font-size: 18px;
  line-height: 40px;
}

.exhibition-title-box h3 {
  font-size: 24px;
  font-weight: normal;
}

.arrow-group {
  display: flex;
  align-items: center;
  /* 确保箭头垂直居中 */
  gap: 15px;
  /* 增加箭头间距 */
}

.arrow-group .arrow-img {
  width: 40px;
  height: 40px;
}


/* 修改箭头样式为纯三角形 */
.arrow {
  width: 0;
  height: 0;
  border-style: solid;
  background: transparent !important;
  /* 移除背景色 */
}

.left .arrow {
  border-width: 15px 0 15px 15px;
  border-color: transparent transparent transparent #B4202F;
}

.right .arrow {
  border-width: 15px 15px 15px 0;
  border-color: transparent #B4202F transparent transparent;
}

.arrow::after {
  content: '';
  position: absolute;
  top: -5px;
  width: 0;
  height: 0;
  border-style: solid;
}

.left .arrow::after {
  right: -10px;
  border-width: 10px 0 10px 10px;
  border-color: transpa rent transparent transparent #e74c3c;
}

.right .arrow::after {
  left: -10px;
  border-width: 10px 10px 10px 0;
  border-color: transparent #e74c3c transparent transparent;
}

/* 添加VR展厅标题样式 */
.vr-exhibition-title {
  text-align: center;
  margin: 10px 0 0px;
}

.vr-title {
  font-size: 63px;
  font-weight: 600;
  font-style: italic;
  font-family: 'Microsoft YaHei';
  color: #333;
  letter-spacing: 6px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.vr-subtitle {
  font-size: 40px;
  font-weight: 600;
  font-style: italic;
  font-family: '华文中宋';
  color: #111;
  font-weight: 300;
  letter-spacing: 1px;
}

.majorView {
  width: 300px;
  height: 100px;
  margin: 20px auto;
  position: relative;
}

.majotTitle {
  width: 50px;
  height: 75px;
}

.majorEngName {
  margin: 0 1px;
  width: 100px;
  height: 8px;

}

.majotBorder {
  position: absolute;
  width: 200px;
  height: 48px;
  z-index: 9;
  left: 37px;
  top: 23px;
}

.majorZhName {
  width: 100px;
  height: 30px;
  position: absolute;
  z-index: 10;
  left: 26%;
  top: 30%;
}

.major-sort {
  list-style: none;
}

.major-item {
  width: 100%;
  height: 34vh;
  border-radius: 60px;
  margin: 20px 0;
}

.major-item .major-img {
  float: right;
  margin-right: 70px;
  margin-top: 50px;
  width: 400px;
  height: 160px;
}

.major-item:first-child {
  background-color: #363636;
  position: sticky;
  top: 50px;
  z-index: 100;
}

.major-item:nth-child(2) {
  background-color: #626262;
  position: sticky;
  top: 80px;
  z-index: 101;
}

.major-item:nth-child(3) {
  background-color: #7D7D7D;
  position: sticky;
  top: 110px;
  z-index: 102;
}

.major-item:nth-child(4) {
  position: sticky;
  top: 140px;
  z-index: 103;
  background-color: #A0A0A0;
}

.major-item:last-child {
  position: sticky;
  top: 170px;
  z-index: 104;
  background-color: #DCDCDC;
}

.major-title-name {
  font-size: 30px;
  color: white;
  font-weight: 600;
  line-height: 32vh;
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 0em;
  font-style: italic;
}

.major-title-zhname {
  padding-left: 60px;
  font-size: 50px;
  color: white;
  font-weight: 550;
  line-height: 32vh;
  font-family: 'Microsoft yahei', Courier, monospace;
  letter-spacing: 0.2em;
}

.more-work {
  width: 100%;
}

.more-work-title {
  color: #B4202F;
  font-weight: 700;
  letter-spacing: 0.2em;
  font-style: italic;
  margin-left: 12%;
}

.more-work-zh-title {
  font-size: 30px;
}

.more-work-eng-title {
  font-size: 25px;
}

.more-work-list-box {
  position: relative;
  margin-top: 30px;
  height: 400px;
  background-color: #be2431;
}

.more-work-list-box-top {
  height: 50%;
  width: 100%;
  /* background-color: pink; */
  background-color: #ffffff;
}

.more-work-list-box-bottom {
  height: 50%;
  width: 100%;
  background-color: #be2431;
}

.more-work-box {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.more-work-list {
  list-style: none;
  display: flex;
  padding-left: 10%;
  margin-top: 20px;
}

.more-work-item {
  float: left;
  width: 18%;
  height: 320px;
  background-color: #fff;
  margin: 5px 20px;
  border-radius: 30px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.more-work-img {
  width: 100%;
  height: 85%;
}

.more-work-name {
  font-size: 11px;
  text-align: center;
  color: #333;
  margin-top: 10px;
  font-weight: 700;
}

.more-work-item {
  transition: transform 0.3s ease;
}

.more-work-item:hover {
  transform: scale(1.1);
  /* 确保从中心点缩放 */
  transform-origin: center;
}
</style>